package game.leon.war.game;

import com.google.protobuf.GeneratedMessage;
import game.leon.engine.net.GameSession;
import game.leon.engine.net.codec.GameRawMessage;

/**
 * User: bianpeng
 * Date: 12-1-12
 */
public class GameMessage {
    private GameSession session;
    private GameRawMessage message;
    public GameMessage(GameSession session, GameRawMessage message) {
        this.session = session;
        this.message = message;
    }
    public GameRawMessage getMessage() {
        return message;
    }
    public GameSession getSession() {
        return session;
    }
    // 回写一个raw message
    public <T extends GeneratedMessage> void write(int message, T vo) {
        getSession().getIoSession().write(new GameRawMessage(message, vo.toByteArray()));
    }
}
